package net.ibizsys.eclipse.studio.data;

import net.ibizsys.eclipse.studio.util.StringKit;

import com.alibaba.fastjson.JSONObject;

/**
 * 用户
 * 
 * @author <a href='http://www.weibo.com/xjtoo' target='_blank'>Enmaai</a>
 */
public class IBizUser extends IBizData
{
	/**
	 * 用户唯一标识
	 */
	private String userId = "";

	/**
	 * 用户登录账户
	 */
	private String account = "";

	/**
	 * 用户名
	 */
	private String name = "";

	/**
	 * 密码
	 */
	private String password = "";

	/**
	 * 身份令牌
	 */
	private String token = "";

	/**
	 * SVN账户
	 */
	private String svnAccount = "";

	/**
	 * SVN密码
	 */
	private String svnPassword = "";

	/**
	 * 远程服务器地址
	 */
	private String remoteUrl = "";

	public IBizUser()
	{

	}

	public IBizUser(JSONObject json)
	{
		init(json);
	}

	@Override
	public void init(JSONObject json)
	{
		this.svnAccount = json.getString("svnusername");
		this.svnPassword = json.getString("svnpasswd");
		this.token = json.getString("loginkey");
		this.userId = json.getString("userid");
		this.name = json.getString("username");
	}

	public String getUserId()
	{
		return userId;
	}

	public void setUserId(String userId)
	{
		this.userId = userId;
	}

	public String getAccount()
	{
		return account;
	}

	public void setAccount(String account)
	{
		this.account = account;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public String getPassword()
	{
		return password;
	}

	public void setPassword(String password)
	{
		this.password = password;
	}

	public String getToken()
	{
		return token;
	}

	public void setToken(String token)
	{
		this.token = token;
	}

	public String getSvnAccount()
	{
		if (StringKit.IsBlank(svnAccount))
		{
			return account;
		}
		return svnAccount;
	}

	public void setSvnAccount(String svnAccount)
	{
		this.svnAccount = svnAccount;
	}

	public String getSvnPassword()
	{
		if (StringKit.IsBlank(svnPassword))
		{
			return password;
		}
		return svnPassword;
	}

	public void setSvnPassword(String svnPassword)
	{
		this.svnPassword = svnPassword;
	}

	public String getRemoteUrl()
	{
		return remoteUrl;
	}

	public void setRemoteUrl(String remoteUrl)
	{
		this.remoteUrl = remoteUrl;
	}

	@Override
	public String getText()
	{
		return getName();
	}
}
